package down.sallai.ml.util.wx;

import down.sallai.ml.bean.WxTextMessageBean;
import down.sallai.ml.util.Constants;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * @description: 微信公众号 事件消息分发$
 * @author: sallai
 * @time: 2022年1月5日 0005 下午 08:28:36 秒
 */
@Slf4j
public class EventDispatcher {
    private static MsgDispatcher msgDispatcher = new MsgDispatcher();;
    public static String processEvent(Map<String, String> map) {
        String msg = "空";
        //处理公众号事件
        switch (map.get("Event")){
            case MessageUtil.EVENT_TYPE_SUBSCRIBE:
                log.info("公众号关注事件");
                WxTextMessageBean wxTextMessageBean = msgDispatcher.buildTextResponeseMsg(map);
                wxTextMessageBean.setContent(Constants.WxReply.SUBSCRIBE_REPLY);
                msg = MessageUtil.textMessageToXml(wxTextMessageBean);
                break;
            case MessageUtil.EVENT_TYPE_UNSUBSCRIBE:
                log.info("公众号解除关注事件");
                break;
            case MessageUtil.EVENT_TYPE_SCAN:
                log.info("扫描二维码事件");
                break;
            case MessageUtil.EVENT_TYPE_LOCATION:
                log.info("位置上报事件");
                break;
            case MessageUtil.EVENT_TYPE_CLICK:
                log.info("自定义菜单点击事件");
                break;
            case MessageUtil.EVENT_TYPE_VIEW:
                log.info("自定义View点击事件");
                break;
            default:
                log.info("未处理该事件类型->" +map.get("Event"));
                break;
        }
        return msg;
    }
}
